package com.zjz.service.role;

import com.zjz.dao.BaseDao;
import com.zjz.dao.role.RoleDao;
import com.zjz.dao.role.RoleDaoImpl;
import com.zjz.pojo.Role;
import org.junit.Test;

import java.sql.Connection;
import java.util.List;

public class RoleServiceImpl implements RoleService{

    // 引入dao
    private RoleDao roleDao;
    public RoleServiceImpl(){
        roleDao = new RoleDaoImpl();
    }

    public List<Role> getRoleList() {

        Connection connection = null; // 为啥不直接获取了事，，因为要关闭了。。
        List<Role> roleList = null;

        try {
            connection = BaseDao.getConnection();
            roleList = roleDao.getRoleList(connection);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            BaseDao.closeResource(connection,null,null);
        }

        return roleList;
    }



/*
    @Test
    public void test(){
        RoleServiceImpl r = new RoleServiceImpl();
        List<Role> roleList = r.getRoleList();
        System.out.println("TestList[0]--" + roleList.get(0).toString());
        System.out.println("----------");
        System.out.println("TestList[0].属性--" + roleList.get(0).getRoleName());
        System.out.println("----------");
        System.out.println(roleList.toString());
    }

    */
}
